<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>playwright自动化测试(1) | 梧桐的学习日记</title><meta name="author" content="梧桐影下月光卧"><meta name="copyright" content="梧桐影下月光卧"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="放弃selenium了，容易被检测，每次测试得随着浏览器版本手动安装驱动，这里的Playwright是微软开源的web自动化测试工具支持主流的浏览器，包含：Chrome、Firefox、Safari、Microsoft Edge 等,同时支持以无头模式、有头模式运行.也支持很多语言，常用的python Node C++ Java都有支持，本人业余玩玩python并提供了同步、异步的 API，可以">
<meta property="og:type" content="article">
<meta property="og:title" content="playwright自动化测试(1)">
<meta property="og:url" content="https://acwy.fun/2023/10/13/playwright%E8%87%AA%E5%8A%A8%E5%8C%961/index.html">
<meta property="og:site_name" content="梧桐的学习日记">
<meta property="og:description" content="放弃selenium了，容易被检测，每次测试得随着浏览器版本手动安装驱动，这里的Playwright是微软开源的web自动化测试工具支持主流的浏览器，包含：Chrome、Firefox、Safari、Microsoft Edge 等,同时支持以无头模式、有头模式运行.也支持很多语言，常用的python Node C++ Java都有支持，本人业余玩玩python并提供了同步、异步的 API，可以">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://upyun.acwy.fun/acwy.fun/playwright.png">
<meta property="article:published_time" content="2023-10-13T01:21:00.000Z">
<meta property="article:modified_time" content="2023-11-29T10:06:13.036Z">
<meta property="article:author" content="梧桐影下月光卧">
<meta property="article:tag" content="python">
<meta property="article:tag" content="自动化">
<meta property="article:tag" content="playwright">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://upyun.acwy.fun/acwy.fun/playwright.png"><link rel="shortcut icon" href="/img/logo.png"><link rel="canonical" href="https://acwy.fun/2023/10/13/playwright%E8%87%AA%E5%8A%A8%E5%8C%961/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: true,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'playwright自动化测试(1)',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-11-29 18:06:13'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pace-js/themes/blue/pace-theme-minimal.min.css"/><script src="https://cdn.jsdelivr.net/npm/pace-js/pace.min.js"></script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/img/logo.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">35</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 目录</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg fixed" id="page-header" style="background-image: url('https://upyun.acwy.fun/acwy.fun/playwright.png')"><nav id="nav"><span id="blog-info"><a href="/" title="梧桐的学习日记"><span class="site-name">梧桐的学习日记</span></a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 目录</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">playwright自动化测试(1)</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-10-13T01:21:00.000Z" title="发表于 2023-10-13 09:21:00">2023-10-13</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-11-29T10:06:13.036Z" title="更新于 2023-11-29 18:06:13">2023-11-29</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>6分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><blockquote>
<p>放弃selenium了，容易被检测，每次测试得随着浏览器版本手动安装驱动，这里的Playwright是微软开源的web自动化测试工具<br>支持主流的浏览器，包含：Chrome、Firefox、Safari、Microsoft Edge 等,同时支持以无头模式、有头模式运行.<br>也支持很多语言，常用的<code>python Node C++ Java</code>都有支持，本人业余玩玩python<br>并提供了同步、异步的 API，可以结合 Pytest 测试框架 使用，并且支持浏览器端的自动化脚本录制。</p>
</blockquote>
<p>直达——&gt;<a target="_blank" rel="noopener" href="https://playwright.bootcss.com/docs/why-playwright">playwright文档</a></p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><h3 id="pip-install-playwright"><a href="#pip-install-playwright" class="headerlink" title="pip install playwright"></a><code>pip install playwright</code></h3><h3 id="安装驱动-playwright-install-chromium"><a href="#安装驱动-playwright-install-chromium" class="headerlink" title="安装驱动 playwright install chromium"></a>安装驱动 <code>playwright install chromium</code></h3><ol>
<li>按需安装，种类有<code>chromium, chrome, chrome-beta, msedge, msedge-beta, msedge-dev, firefox, webkit</code></li>
<li>如果pyinstaller 打包报错 <code>Please run the following command to download new browsers</code><br>使用<code>PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium</code></li>
</ol>
<h2 id="同步API"><a href="#同步API" class="headerlink" title="同步API"></a>同步API</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> playwright.sync_api <span class="keyword">import</span> sync_playwright</span><br><span class="line"><span class="comment"># with管理器（方便使用，但是js加载如果有事件监听太多可能会崩溃）</span></span><br><span class="line"><span class="keyword">with</span> sync_playwright() <span class="keyword">as</span> p:</span><br><span class="line">    <span class="comment"># 可以选择chromium、firefox和webkit运行chrome浏览器</span></span><br><span class="line">    <span class="comment"># False是有头模式，默认为true是无头模式</span></span><br><span class="line">    browser = p.chromium.launch(headless=<span class="literal">False</span>)</span><br><span class="line">    context = browser.new_context()</span><br><span class="line">    <span class="comment"># 打开新页面</span></span><br><span class="line">    page = context.new_page()</span><br><span class="line">    <span class="comment"># 调到指定页面</span></span><br><span class="line">    page.goto(<span class="string">&#x27;https://www.baidu.com/&#x27;</span>)  <span class="comment"># 打开百度地址</span></span><br><span class="line">    <span class="comment"># 标题</span></span><br><span class="line">    <span class="built_in">print</span>(page.title())</span><br><span class="line">    page.fill(<span class="string">&#x27;#kw&#x27;</span>, <span class="string">&#x27;python&#x27;</span>)           <span class="comment"># 输入内容</span></span><br><span class="line">    page.click(<span class="string">&#x27;#su&#x27;</span>)                    <span class="comment"># 点击搜索</span></span><br><span class="line">    <span class="comment"># 关闭</span></span><br><span class="line">    browser.close()</span><br><span class="line">    </span><br><span class="line"><span class="comment"># 建议使用（一般情况用with就可以了）</span></span><br><span class="line">p = sync_playwright().start()</span><br><span class="line">browser = p.chromium.launch()</span><br><span class="line"><span class="comment"># ... 后面一样</span></span><br></pre></td></tr></table></figure>

<h2 id="基础用法"><a href="#基础用法" class="headerlink" title="基础用法"></a>基础用法</h2><h3 id="定位-支持xpath、css"><a href="#定位-支持xpath、css" class="headerlink" title="定位(支持xpath、css)"></a>定位(支持xpath、css)</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 先定位再点击</span></span><br><span class="line">element = page.locator(<span class="string">&#x27;#su&#x27;</span>)</span><br><span class="line">element.click()</span><br><span class="line"><span class="comment"># 可直接点击</span></span><br><span class="line">page.click(<span class="string">&#x27;xpath=//*[@id=&quot;s-top-left&quot;]/a[1]&#x27;</span>)</span><br><span class="line"><span class="comment"># 省略xpath</span></span><br><span class="line">page.click(<span class="string">&#x27;//*[@id=&quot;s-top-left&quot;]/a[1]&#x27;</span>)</span><br><span class="line"><span class="comment"># css定位</span></span><br><span class="line">page.click(<span class="string">&#x27;input[name=&quot;goto_tdouya_homepage&quot;]&#x27;</span>)</span><br><span class="line"><span class="comment"># 悬停</span></span><br><span class="line">page.locator(<span class="string">&quot;//span[text()=&#x27;设置&#x27;]&quot;</span>).hover()</span><br><span class="line"><span class="comment"># 第一个没有对新闻加引号，表示模糊匹配，对大小写不敏感</span></span><br><span class="line"><span class="comment"># 第二个对新闻加了引号，精确匹配，对大小写敏感</span></span><br><span class="line"><span class="built_in">print</span>(page.locator(<span class="string">&quot;text=新闻&quot;</span>))</span><br><span class="line"><span class="built_in">print</span>(page.locator(<span class="string">&quot;text=&#x27;新闻&#x27;&quot;</span>))</span><br></pre></td></tr></table></figure>

<h3 id="获取内容"><a href="#获取内容" class="headerlink" title="获取内容"></a>获取内容</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 获取源码，可搭配beautifulsoup</span></span><br><span class="line">html = page.content()</span><br><span class="line"><span class="comment"># 所有img节点，for循环一下获取单个的。。。详情可以看第二章例子</span></span><br><span class="line">imgs = page.query_selector_all(<span class="string">&#x27;img&#x27;</span>)</span><br><span class="line"><span class="comment"># 获取单个节点</span></span><br><span class="line">ele1 = page.query_selector(<span class="string">&#x27;#id.class&#x27;</span>)</span><br></pre></td></tr></table></figure>
<h3 id="获取属性"><a href="#获取属性" class="headerlink" title="获取属性"></a>获取属性</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 标签a的链接</span></span><br><span class="line">a.get_attribute(<span class="string">&#x27;href&#x27;</span>)</span><br><span class="line"><span class="comment"># 标签a的文本</span></span><br><span class="line">a.inner_text()</span><br><span class="line"><span class="comment"># 输入框的值</span></span><br><span class="line"><span class="built_in">input</span>.input_value()</span><br></pre></td></tr></table></figure>

<h3 id="文本输入"><a href="#文本输入" class="headerlink" title="文本输入"></a>文本输入</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">page.goto(<span class="string">&#x27;https://www.baidu.com/&#x27;</span>)  <span class="comment"># 打开百度地址</span></span><br><span class="line">page.fill(<span class="string">&#x27;#kw&#x27;</span>, <span class="string">&#x27;python&#x27;</span>)           <span class="comment"># 输入内容</span></span><br><span class="line">page.click(<span class="string">&#x27;#su&#x27;</span>)                    <span class="comment"># 点击搜索</span></span><br></pre></td></tr></table></figure>

<h3 id="模拟人工输入"><a href="#模拟人工输入" class="headerlink" title="模拟人工输入"></a>模拟人工输入</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># delay 是设置输入延迟时间，眼不然看不到效果</span></span><br><span class="line">page.get_by_placeholder(<span class="string">&#x27;手机号或邮箱&#x27;</span>).<span class="built_in">type</span>(<span class="string">&#x27;1760123456&#x27;</span>,delay=<span class="number">1000</span>)</span><br></pre></td></tr></table></figure>

<h3 id="等待"><a href="#等待" class="headerlink" title="等待"></a>等待</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 等待元素出现 超时5秒</span></span><br><span class="line"><span class="comment"># visible：指定元素必须可见，默认为 False。</span></span><br><span class="line"><span class="comment"># hidden：指定元素必须隐藏，默认为 False。</span></span><br><span class="line">page.wait_for_selector(<span class="string">&#x27;#my-element&#x27;</span>, &#123; timeout: <span class="number">5000</span> &#125;)</span><br><span class="line"><span class="comment"># load：页面完全加载完成。</span></span><br><span class="line"><span class="comment"># domcontentloaded：DOM 内容加载完成。</span></span><br><span class="line"><span class="comment"># networkidle0：网络空闲状态时。</span></span><br><span class="line"><span class="comment"># networkidle2：网络连接数稳定且超过 500 毫秒。</span></span><br><span class="line">page.wait_for_load_state(<span class="string">&#x27;networkidle&#x27;</span>)</span><br></pre></td></tr></table></figure>

<h3 id="截图"><a href="#截图" class="headerlink" title="截图"></a>截图</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># page.screenshot(path=None, *, full_page=True, clip=None, quality=None, omit_background=False)</span></span><br><span class="line"><span class="comment"># path：指定截图保存的文件路径和文件名。</span></span><br><span class="line"><span class="comment"># full_page：指定截图是否包含整个页面，默认为 True。</span></span><br><span class="line"><span class="comment"># clip：指定截图的大小和位置。</span></span><br><span class="line"><span class="comment"># quality：指定截图的质量。</span></span><br><span class="line"><span class="comment"># omit_background：指定是否忽略背景色。</span></span><br><span class="line">page.screenshot(path=<span class="string">&#x27;example.png&#x27;</span>, full_page=<span class="literal">True</span>)</span><br><span class="line">page.screenshot(clip=&#123;<span class="string">&#x27;x&#x27;</span>: <span class="number">0</span>, <span class="string">&#x27;y&#x27;</span>: <span class="number">0</span>, <span class="string">&#x27;width&#x27;</span>: <span class="number">800</span>, <span class="string">&#x27;height&#x27;</span>: <span class="number">600</span>&#125;)</span><br></pre></td></tr></table></figure>

<h3 id="选择框"><a href="#选择框" class="headerlink" title="选择框"></a>选择框</h3><ol>
<li>示例：<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">select</span> <span class="attr">id</span>=<span class="string">&quot;xz&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;bj&quot;</span>&gt;</span>北京<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;sh&quot;</span>&gt;</span>上海<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">option</span> <span class="attr">value</span>=<span class="string">&quot;sz&quot;</span>&gt;</span>深圳<span class="tag">&lt;/<span class="name">option</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">select</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
<li>操作：<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">page.select_option(<span class="string">&#x27;#xz&#x27;</span>, <span class="string">&#x27;sh&#x27;</span>)          <span class="comment"># 通过value选择</span></span><br><span class="line">page.select_option(<span class="string">&#x27;#xz&#x27;</span>, <span class="string">&#x27;2&#x27;</span>)           <span class="comment"># 通过下标选择</span></span><br><span class="line">page.select_option(<span class="string">&#x27;#xz&#x27;</span>, <span class="string">&#x27;上海&#x27;</span>)         <span class="comment"># 通过label选择</span></span><br></pre></td></tr></table></figure></li>
</ol>
<h3 id="切换浏览器页面"><a href="#切换浏览器页面" class="headerlink" title="切换浏览器页面"></a>切换浏览器页面</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">with</span> context.expect_page() <span class="keyword">as</span> new_page_info:</span><br><span class="line">    page.click(<span class="string">&#x27;打开新链接&#x27;</span>) </span><br><span class="line">new_page = new_page_info.value</span><br><span class="line">new_page.wait_for_load_state()</span><br></pre></td></tr></table></figure>

<h3 id="上传文件"><a href="#上传文件" class="headerlink" title="上传文件"></a>上传文件</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">page.goto(<span class="string">&#x27;https://deershare.com/send&#x27;</span>)  <span class="comment"># 打开地址</span></span><br><span class="line"><span class="comment"># (定位元素， 本地文件路径)</span></span><br><span class="line">page.set_input_files(<span class="string">&#x27;input[type=file]&#x27;</span>, <span class="string">r&#x27;D:\test.txt&#x27;</span>)</span><br></pre></td></tr></table></figure>

<h3 id="获取保存的cookie直接登录"><a href="#获取保存的cookie直接登录" class="headerlink" title="获取保存的cookie直接登录"></a>获取保存的cookie直接登录</h3><ol>
<li>以一个测试平台为例：<a target="_blank" rel="noopener" href="http://demo.liumatest.cn/#/home/dashboard">http://demo.liumatest.cn/#/home/dashboard</a><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">with</span> sync_playwright() <span class="keyword">as</span> p:</span><br><span class="line">    browser = p.chromium.launch(headless=<span class="literal">False</span>, slow_mo=<span class="number">5000</span>)  <span class="comment"># 设置了每步等待时间为5s</span></span><br><span class="line">    context = browser.new_context()</span><br><span class="line">    page = context.new_page()  <span class="comment"># 打开一个页面</span></span><br><span class="line">    page.goto(<span class="string">&#x27;http://demo.liumatest.cn/#/home/dashboard&#x27;</span>)  <span class="comment"># 打开地址</span></span><br><span class="line">    <span class="comment"># 输入账号密码登录</span></span><br><span class="line">    page.fill(<span class="string">&#x27;#username&#x27;</span>,<span class="string">&#x27;demo&#x27;</span>)  <span class="comment"># 输入账号</span></span><br><span class="line">    page.fill(<span class="string">&#x27;#password&#x27;</span>,<span class="string">&#x27;123456&#x27;</span>)  <span class="comment"># 输入密码</span></span><br><span class="line">    page.click(<span class="string">&#x27;#login&#x27;</span>)  <span class="comment"># 点击登录</span></span><br><span class="line">    context.storage_state(path=<span class="string">&quot;cookie.json&quot;</span>)   <span class="comment"># 保存storage_state 到JSON文件</span></span><br><span class="line">    page.wait_for_timeout(<span class="number">2000</span>)</span><br><span class="line">    browser.close()</span><br></pre></td></tr></table></figure></li>
<li>使用cookie登录<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">with</span> sync_playwright() <span class="keyword">as</span> p:</span><br><span class="line">    browser = p.chromium.launch(headless=<span class="literal">False</span>, slow_mo=<span class="number">5000</span>)</span><br><span class="line">    context = browser.new_context(storage_state=<span class="string">&quot;cookie.json&quot;</span>)</span><br><span class="line">    page = context.new_page()  <span class="comment"># 打开一个页面</span></span><br><span class="line">    page.goto(<span class="string">&#x27;http://demo.liumatest.cn/#/home/dashboard&#x27;</span>)</span><br><span class="line">    page.screenshot(path=<span class="string">&quot;image.png&quot;</span>)</span><br><span class="line">    browser.close()</span><br></pre></td></tr></table></figure></li>
</ol>
<h2 id="异步API"><a href="#异步API" class="headerlink" title="异步API"></a>异步API</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> asyncio</span><br><span class="line"><span class="keyword">from</span> playwright <span class="keyword">import</span> async_playwright</span><br><span class="line"><span class="keyword">async</span> <span class="keyword">def</span> <span class="title function_">main</span>():</span><br><span class="line">    <span class="keyword">async</span> <span class="keyword">with</span> async_playwright() <span class="keyword">as</span> p:</span><br><span class="line">        browser = <span class="keyword">await</span> p.chromium.launch(headless=<span class="literal">False</span>)</span><br><span class="line">        page = <span class="keyword">await</span> browser.newPage()</span><br><span class="line">        <span class="keyword">await</span> page.goto(<span class="string">&#x27;https://www.baidu.com/&#x27;</span>)</span><br><span class="line">        <span class="keyword">await</span> page.screenshot(path=<span class="string">&#x27;example-2.png&#x27;</span>)</span><br><span class="line">        <span class="keyword">await</span> browser.close()</span><br><span class="line">asyncio.get_event_loop().run_until_complete(main())</span><br></pre></td></tr></table></figure>
<h2 id="模拟手机模式"><a href="#模拟手机模式" class="headerlink" title="模拟手机模式"></a>模拟手机模式</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> playwright <span class="keyword">import</span> sync_playwright</span><br><span class="line"><span class="keyword">with</span> sync_playwright() <span class="keyword">as</span> p:</span><br><span class="line">    iphone_11 = p.devices[<span class="string">&#x27;iPhone 11 Pro&#x27;</span>]</span><br><span class="line">    browser = p.chromium.launch(headless=<span class="literal">False</span>)</span><br><span class="line">    context = browser.newContext(**iphone_11, locale=<span class="string">&#x27;zh-CN&#x27;</span>)</span><br><span class="line">    page = context.newPage()</span><br><span class="line">    page.goto(<span class="string">&#x27;https://www.baidu.com/&#x27;</span>)</span><br><span class="line">    page.click(<span class="string">&#x27;#logo&#x27;</span>)</span><br><span class="line">    page.screenshot(path=<span class="string">&#x27;colosseum-iphone.png&#x27;</span>)</span><br><span class="line">    browser.close()</span><br></pre></td></tr></table></figure>
<h2 id="浏览器中运行JS"><a href="#浏览器中运行JS" class="headerlink" title="浏览器中运行JS"></a>浏览器中运行JS</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> playwright <span class="keyword">import</span> sync_playwright</span><br><span class="line"><span class="keyword">with</span> sync_playwright() <span class="keyword">as</span> p:</span><br><span class="line">    browser = p.chromium.launch(headless=<span class="literal">False</span>, slowMo=<span class="number">1000</span>)</span><br><span class="line">    page = browser.newPage()</span><br><span class="line">    page.goto(<span class="string">&#x27;https://www.baidu.com/&#x27;</span>)</span><br><span class="line">    dimensions = page.evaluate(<span class="string">&#x27;&#x27;&#x27;() =&gt; &#123;</span></span><br><span class="line"><span class="string">      return &#123;</span></span><br><span class="line"><span class="string">        width: document.documentElement.clientWidth,</span></span><br><span class="line"><span class="string">        height: document.documentElement.clientHeight,</span></span><br><span class="line"><span class="string">        deviceScaleFactor: window.devicePixelRatio</span></span><br><span class="line"><span class="string">      &#125;</span></span><br><span class="line"><span class="string">    &#125;&#x27;&#x27;&#x27;</span>)</span><br><span class="line">    <span class="built_in">print</span>(dimensions)</span><br><span class="line">    browser.close()</span><br></pre></td></tr></table></figure>

<h2 id="录制脚本"><a href="#录制脚本" class="headerlink" title="录制脚本"></a>录制脚本</h2><ol>
<li>命令行键入 –help 看到所有可后接选项<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">playwright codegen --help</span><br><span class="line">playwright codegen --help</span><br></pre></td></tr></table></figure></li>
<li>从起始页为xingzheai.cn开始录制<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">playwright codegen https://xingzheai.cn/</span><br></pre></td></tr></table></figure></li>
<li>打开xingzheai.cn，用Chromium驱动，将结果保存为my.py的python文件，可以打开这个文件重现<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">playwright codegen --target python -o &#x27;my.py&#x27; -b chromium https://xingzheai.cn/</span><br><span class="line">-target：规定生成脚本的语言，有JS和Python两种，默认为Python</span><br><span class="line">-b：指定浏览器驱动</span><br><span class="line">-o：将录制的脚本保存到一个文件</span><br></pre></td></tr></table></figure></li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://acwy.fun">梧桐影下月光卧</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://acwy.fun/2023/10/13/playwright%E8%87%AA%E5%8A%A8%E5%8C%961/">https://acwy.fun/2023/10/13/playwright%E8%87%AA%E5%8A%A8%E5%8C%961/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://acwy.fun" target="_blank">梧桐的学习日记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/python/">python</a><a class="post-meta__tags" href="/tags/%E8%87%AA%E5%8A%A8%E5%8C%96/">自动化</a><a class="post-meta__tags" href="/tags/playwright/">playwright</a></div><div class="post_share"><div class="social-share" data-image="https://upyun.acwy.fun/acwy.fun/playwright.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/img/wechatpay.png" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/wechatpay.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/img/alipay.png" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="/img/alipay.png" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/10/29/playwright%E8%87%AA%E5%8A%A8%E5%8C%962/" title="playwright自动化测试(2)"><img class="cover" src= "" data-lazy-src="https://upyun.acwy.fun/acwy.fun/playwright.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">playwright自动化测试(2)</div></div></a></div><div class="next-post pull-right"><a href="/2023/09/15/win10%E7%B3%BB%E7%BB%9F%E6%9B%B4%E6%96%B0%E5%85%B3%E9%97%AD/" title="关闭win10系统更新，解决图标变白"><img class="cover" src= "" data-lazy-src="https://img1.baidu.com/it/u=3640415815,4244863351&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">关闭win10系统更新，解决图标变白</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2023/10/29/playwright%E8%87%AA%E5%8A%A8%E5%8C%962/" title="playwright自动化测试(2)"><img class="cover" src= "" data-lazy-src="https://upyun.acwy.fun/acwy.fun/playwright.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-10-29</div><div class="title">playwright自动化测试(2)</div></div></a></div><div><a href="/2022/01/10/Beautifulsoup4/" title="1.1 BeautifulSoup简单介绍"><img class="cover" src= "" data-lazy-src="https://pic1.zhimg.com/v2-a4c6b2b3504284423e625419eef9760c_r.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-01-10</div><div class="title">1.1 BeautifulSoup简单介绍</div></div></a></div><div><a href="/2023/04/10/xpath/" title="1.2 xpath简单介绍"><img class="cover" src= "" data-lazy-src="https://www.w3cschool.cn/attachments/image/20161103/1478161528585228.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-04-10</div><div class="title">1.2 xpath简单介绍</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/img/logo.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">梧桐影下月光卧</div><div class="author-info__description">分享个人学习路上的小知识</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">28</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">35</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://beau.acwy.fun"><i class="fa-solid fa-envelope"></i><span>点击联系我</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content"><b> <font color="#e66b6d">欢</font> <font color="#e66d98">迎</font> <font color="#e66cc6">访</font> <font color="#cc6de6">问</font> <font color="#9770e6">a</font> <font color="#6d93e6">c</font> <font color="#6fcde6">w</font> <font color="#72e6b6">y</font> <font color="#72e689">的</font> <font color="#99e670">学</font> <font color="#cde670">习</font> <font color="#e6df72">日</font> <font color="#e6c073">记</font> </b> <p align="center"> <img src= "" data-lazy-src="https://upyun.acwy.fun/acwy.fun/公告1.gif" width="50" alt="mao"> </p> <p align="center">微信：acwy0718</p> <p align="center">邮箱：awy0718@gmail.com</p></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">安装</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#pip-install-playwright"><span class="toc-number">1.1.</span> <span class="toc-text">pip install playwright</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%89%E8%A3%85%E9%A9%B1%E5%8A%A8-playwright-install-chromium"><span class="toc-number">1.2.</span> <span class="toc-text">安装驱动 playwright install chromium</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%90%8C%E6%AD%A5API"><span class="toc-number">2.</span> <span class="toc-text">同步API</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9F%BA%E7%A1%80%E7%94%A8%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text">基础用法</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9A%E4%BD%8D-%E6%94%AF%E6%8C%81xpath%E3%80%81css"><span class="toc-number">3.1.</span> <span class="toc-text">定位(支持xpath、css)</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96%E5%86%85%E5%AE%B9"><span class="toc-number">3.2.</span> <span class="toc-text">获取内容</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96%E5%B1%9E%E6%80%A7"><span class="toc-number">3.3.</span> <span class="toc-text">获取属性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E6%9C%AC%E8%BE%93%E5%85%A5"><span class="toc-number">3.4.</span> <span class="toc-text">文本输入</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A8%A1%E6%8B%9F%E4%BA%BA%E5%B7%A5%E8%BE%93%E5%85%A5"><span class="toc-number">3.5.</span> <span class="toc-text">模拟人工输入</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%AD%89%E5%BE%85"><span class="toc-number">3.6.</span> <span class="toc-text">等待</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%88%AA%E5%9B%BE"><span class="toc-number">3.7.</span> <span class="toc-text">截图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%89%E6%8B%A9%E6%A1%86"><span class="toc-number">3.8.</span> <span class="toc-text">选择框</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%87%E6%8D%A2%E6%B5%8F%E8%A7%88%E5%99%A8%E9%A1%B5%E9%9D%A2"><span class="toc-number">3.9.</span> <span class="toc-text">切换浏览器页面</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6"><span class="toc-number">3.10.</span> <span class="toc-text">上传文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96%E4%BF%9D%E5%AD%98%E7%9A%84cookie%E7%9B%B4%E6%8E%A5%E7%99%BB%E5%BD%95"><span class="toc-number">3.11.</span> <span class="toc-text">获取保存的cookie直接登录</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BC%82%E6%AD%A5API"><span class="toc-number">4.</span> <span class="toc-text">异步API</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%A8%A1%E6%8B%9F%E6%89%8B%E6%9C%BA%E6%A8%A1%E5%BC%8F"><span class="toc-number">5.</span> <span class="toc-text">模拟手机模式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B5%8F%E8%A7%88%E5%99%A8%E4%B8%AD%E8%BF%90%E8%A1%8CJS"><span class="toc-number">6.</span> <span class="toc-text">浏览器中运行JS</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BD%95%E5%88%B6%E8%84%9A%E6%9C%AC"><span class="toc-number">7.</span> <span class="toc-text">录制脚本</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('https://upyun.acwy.fun/acwy.fun/playwright.png')"><div id="footer-wrap"><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><div> <a href="https://beian.miit.gov.cn/" target="_blank">豫ICP备2023010490号-1</a> </div> <div> <a style="display:flex;justify-content:center;align-items:center;" target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=41152402000204"> <img src= "" data-lazy-src="/img/beian.png" style="width:20px;height:20px;margin:0 5px"> <span>豫公网安备 41152402000204号</span> </a> </div> <div> <a style="display:flex;justify-content:center;" href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" target="_blank"> <span>本网站由</span> <img style="height:30px;margin:0 3px" src= "" data-lazy-src="/img/upyun_logo5.png"> <span>提供CDN加速/云存储服务</span> </a> <div/></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/fireworks.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script></div></body></html>